#include<iostream>
using namespace std;
class Solution {
public:
    int minChanges(int n, int k) {
        if (n == k)
            return 0;
        if (n < k)
            return -1;
        int ans = 0;
        while (n > k) {
            int a1 = n % 2, a2 = k % 2;
            if (a1 > a2)
                ++ans;
            else if (a1 < a2)
                return -1;
            n /= 2;
            k /= 2;
        }
        return ans;
    }
};